package com.ruoyi.project.qyxy.jlscore.controller;

import java.util.List;

import com.ruoyi.project.qyxy.jlscoredtl.domain.JlOrgScoreDetail;
import com.ruoyi.project.qyxy.jlscoredtl.service.IJlOrgScoreDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.qyxy.jlscore.domain.JlOrgScore;
import com.ruoyi.project.qyxy.jlscore.service.IJlOrgScoreService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 监理企业得分Controller
 * 
 * @author lcl
 * @date 2021-03-14
 */
@RestController
@RequestMapping("/qyxy/jlscore")
public class JlOrgScoreController extends BaseController
{
    @Autowired
    private IJlOrgScoreService jlOrgScoreService;

    @Autowired
    private IJlOrgScoreDetailService jlOrgScoreDetailService;

    /**
     * 查询监理企业得分列表
     */
    @GetMapping("/list")
    public TableDataInfo list(JlOrgScore jlOrgScore)
    {
        startPage();
        List<JlOrgScore> list = jlOrgScoreService.selectJlOrgScoreList(jlOrgScore);
        return getDataTable(list);
    }

    /**
     * 导出监理企业得分列表
     */
    @Log(title = "监理企业得分", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(JlOrgScore jlOrgScore)
    {
        List<JlOrgScore> list = jlOrgScoreService.selectJlOrgScoreList(jlOrgScore);
        ExcelUtil<JlOrgScore> util = new ExcelUtil<JlOrgScore>(JlOrgScore.class);
        return util.exportExcel(list, "jlscore");
    }

    /**
     * 获取监理企业得分详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        JlOrgScore jlOrgScore = jlOrgScoreService.selectJlOrgScoreById(id);
        JlOrgScoreDetail jlOrgScoreDetail = new JlOrgScoreDetail();
        jlOrgScoreDetail.setJlId(jlOrgScore.getId());
        jlOrgScore.setList(jlOrgScoreDetailService.selectJlOrgScoreDetailList(jlOrgScoreDetail));
        return AjaxResult.success(jlOrgScore);
    }

    /**
     * 新增监理企业得分
     */
    @Log(title = "监理企业得分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JlOrgScore jlOrgScore)
    {
        return toAjax(jlOrgScoreService.insertJlOrgScore(jlOrgScore));
    }

    /**
     * 修改监理企业得分
     */
    @Log(title = "监理企业得分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JlOrgScore jlOrgScore)
    {
        return toAjax(jlOrgScoreService.updateJlOrgScore(jlOrgScore));
    }

    /**
     * 删除监理企业得分
     */
    @Log(title = "监理企业得分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jlOrgScoreService.deleteJlOrgScoreByIds(ids));
    }
}
